const getComponentsName = fileName => {
  return fileName
    .split("/")[1]
    .replace(/\.\w+$/, "")
    .replace(/^\w/, c => c.toUpperCase());
};

// eslint-disable-next-line no-undef
const requireComponent = require.context("./", true, /\.vue$/);

const cmps = {};
const whitelist = [];
requireComponent.keys().forEach(fileName => {
  const config = requireComponent(fileName);
  const componentName = getComponentsName(fileName);
  if (!whitelist.includes(componentName)) {
    config && componentName && (cmps[componentName] = config.default || config);
  }
});

export { cmps };
export default cmps;
